<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>充值审核</title>

    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css?v=3.3.5}"/>
    <link href="../../resource/css/font-awesome.min.css?v=4.4.0" rel="stylesheet"
          th:href="@{/resource/css/font-awesome.min.css?v=4.4.0}"/>
    <!-- Morris -->
    <link href="http://cdn.viptool.cn/lib/morris.js/0.4.3/morris.css" rel="stylesheet">
    <link href="../../resource/css/animate.min.css" rel="stylesheet" th:href="@{/resource/css/animate.min.css}"/>

    <link href="../../resource/css/style.min.css?v=4.0.0" rel="stylesheet"
          th:href="@{/resource/css/style.min.css?v=4.0.0}"/>
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>

    <style type="text/css">
        .hr-line-dashed {
            margin: 10px 0;
            height: 1px;
            border-top: 1px dashed #e7eaec;
            background-color: #fff;
            color: #fff;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content tooltip-demo">
    <!--search-->
    <form role="form" id="searchForm" class="search-panel" method="get" th:object="${condition}">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <div class="form-inline">
                            <input type="hidden" th:value="${pageIndex}" name="pageIndex"/>
                            <input type="hidden" th:value="*{checkStatus}" name="deliverStatus"/>
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="userKey">下单用户：</label>
                                <input type="text" class="form-control input-sm mb10" id="userKey" th:value="*{userKey}"
                                       name="userKey" placeholder="用户名/姓名" style="width: 156px;"/>
                            </div>
                        </div>
                        <p style="height: 20px;"></p>
                        <div class="form-inline">
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="createTimePick">创建时间：</label>
                                <input readonly type="text" class="form-control input-sm mb10 data-range-pick"
                                       id="createTimePick" name="createTimePick" start-element="#beginTime"
                                       end-element="#endTime" placeholder="开始时间-结束时间" style="width: 377px;"/>
                                <input type="hidden" th:value="*{beginTime}" id="beginTime" name="beginTime"/>
                                <input type="hidden" th:value="*{endTime}" id="endTime" name="endTime"/>
                            </div>
                            <div class="form-group m-r-sm">
                                <button type="button" onclick="orderHandler.search(1)"
                                        class="btn btn-primary btn-sm m-b-none searchBtn">筛选
                                </button>
                                <button type="button" onclick="orderHandler.searchAll()"
                                        class="btn btn-primary btn-sm m-b-none">显示全部
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <!--search-->
    <!--list-->
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins m-b-none">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active" th:class="${condition.checkStatus==-1?'active':''}">
                            <a th:href="@{/user/recharge/list}" href="#">全部</a>
                        </li>
                        <li th:class="${condition.checkStatus==0?'active':''}">
                            <a th:href="@{/user/recharge/list(checkStatus=0)}">待审核</a>
                        </li>
                        <li th:class="${condition.checkStatus==1?'active':''}">
                            <a th:href="@{/user/recharge/list(checkStatus=1)}">审核成功</a>
                        </li>
                        <li th:class="${condition.checkStatus==1?'active':''}">
                            <a th:href="@{/user/recharge/list(checkStatus=1)}">审核失败</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="panel-body">
                                <table class="table table-bordered table-hover table-center">
                                    <thead>
                                    <tr>
                                        <th>充值编号</th>
                                        <th>用户名</th>
                                        <th>姓名</th>
                                        <th>充值金额</th>
                                        <th>状态</th>
                                        <th>创建时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    <tr th:each="recharge:${rechargeList}">
                                        <td th:text="${recharge.id}"></td>
                                        <td th:text="${recharge.userPO.username}"></td>
                                        <td th:text="${recharge.userPO.realName}"></td>
                                        <td th:text="${recharge.amount}"></td>
                                        <td th:class="${recharge.statusClass()}"
                                            th:text="${recharge.checkStatus.desc}"></td>
                                        <td th:text="${#temporals.format(recharge.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                        <td>
                                            <button th:onclick="listHandler.checkModal([[${recharge.id}]])"
                                                    onclick="listHandler.checkModal('1')">审核
                                            </button>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                                <p style="float: left; margin: 20px 0;">
                                    共<span th:text="${totalRecords}"></span>条记录，当前第<span th:text="${pageIndex}"></span>/<span
                                        th:text="${totalPages==0?1:totalPages}"></span>，每页20条记录
                                </p>
                                <ul style="float: right;" class="pagination pagination-split">
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="check_modal" style="display: none;">
    <div class="form-horizontal" style="width: 479px;height: 100px">
        <input type="hidden" id="check_recharge_id"/>
        <div class="form-group">
            <label class="col-sm-4 control-label">*审核：</label>
            <div class="col-sm-8">
                <select id="check_status">
                    <option value="1">审核成功</option>
                    <option value="2">审核失败</option>
                </select>
            </div>
        </div>
    </div>
</div>

<!--基础框架js-->
<script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js?v=2.1.4}"></script>
<script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js(123123)}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js"></script>

<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>

<script type="text/javascript" th:inline="javascript">
    const pageIndex = /*[[${pageIndex}]]*/  1;
    const totalPages = /*[[${totalPages}]]*/  1;
    const pageUri = /*[[@{/user/recharge/list}]]*/  "";
    const apiUri = /*[[@{/user/recharge/check}]]*/  "";
</script>
<script>
    var checkModal = $("#check_modal").modal("审核", function () {
        let rechargeId = $("#check_recharge_id").val();
        let checkStatus = $("#check_status").val();
        hot.ajax(apiUri, {
            status: checkStatus,
            rechargeId: rechargeId,
            remark: ""
        }, function (apiResult) {
            if (apiResult.resultCode === 2000) {
                hot.tip.success("操作成功", function () {
                    window.location.reload();
                })
            } else {
                hot.tip.error("操作失败--" + apiResult.resultMsg);
            }
        }, function () {
        }, "post");
    });
    $(function () {
        //初始化分页
        var pageinate = new hot.paging(".pagination", pageIndex, totalPages, 7);

        pageinate.init(function (p) {
            listHandler.search(p);
        });
        $(document).keyup(function (event) {
            if (event.keyCode === 13) {
                $(".searchBtn").trigger("click");
            }
        });
    });

    var listHandler = {
        search: function (pageIndex) {
            $("input[name=pageIndex]").val(pageIndex);
            $("#searchForm").submit();
        },
        searchAll: function () {
            window.location.href = pageUri;
        },
        checkModal: function (rechargeId) {
            checkModal.show(function () {
                $("#check_recharge_id").val(rechargeId);
            });
        }
    }
</script>
</body>
</html>
